package com.yt.fras.handler;

import com.alibaba.fastjson.JSON;
import com.yt.fras.constant.ResultCode;
import com.yt.fras.pojo.base.JsonResult;
import com.yt.fras.utils.ResultTool;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * ClassName:GlobalExceptionHandler
 * Package:com.yt.fras.handler
 * Description:
 * 拦截异常处理器
 *
 * @date:2021/8/17 10:19
 * @author:yt
 */

//@ControllerAdvice
public class GlobalExceptionHandler {

    /**
     * 拦截运行异常出现的错误~~~
     *
     * @return
     */
    @ExceptionHandler(RuntimeException.class)
    @ResponseBody
    public String exceptionHandler() {
        JsonResult result = ResultTool.fail(ResultCode.SYSTEM_ERROR);
        return JSON.toJSONString(result);
    }
}
